﻿<?php include SYSDIR_VIEW ."/common/header.html";?>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 菜单管理 <span class="c-gray en">&gt;</span> 菜单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form class="text-c" method="get" action="/admin/manager/menu.php">
        菜单名称: <input type="text" name="menu_name" value="<?php echo $_GET['menu_name'];?>" style="width:150px" class="input-text">
		<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜菜单</button>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="delAll('chk_ids');" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a class="btn btn-primary radius" data-title="添加菜单" onclick="layer_show('添加菜单','/admin/manager/menu_edit.php','','480')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加菜单</a></span> <span class="r">共有数据：<strong><?php echo count($menu_list);?></strong> 条</span> </div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th><input type="checkbox" name="" value=""></th>
					<th>菜单ID</th>
					<th>菜单名称</th>
					<th>菜单链接</th>
					<th>是否显示</th>
					<th>菜单级别</th>
					<th>上级菜单</th>
					<th>排序</th>
					<th>系统</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
            <?php foreach ($menu_list as $key=>$val) {?>
				<tr class="text-c">
                    <td><input type="checkbox" value="<?php echo $val['menu_id'];?>" class="chk_ids"></td>
                    <td><?php echo $val['menu_id'];?></td>
                    <td><?php echo $val['menu_name'];?></td>
                    <td><?php echo $val['menu_link'];?></td>
                    <td><?php echo $val['menu_show'];?></td>
                    <td><?php echo $val['menu_level'];?></td>
                    <td><?php echo $val['menu_par_id'];?></td>
                    <td><?php echo $val['menu_order'];?></td>
                    <td><?php echo $val['menu_system'];?></td>
                    <td class="f-14 td-manage"><a style="text-decoration:none" class="ml-5" onClick="layer_show('编辑菜单','/admin/manager/menu_edit.php?id=<?php echo $val['menu_id'];?>','','480')"" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5" onClick="del(<?php echo $val['menu_id'];?>)" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>

				</tr>
            <?php }?>
			</tbody>
		</table>
	</div>
</div>

<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,8]}// 不参与排序的列
	]
});

//删除
function del(ids){
    if (confirm('确定要删除吗？')) {
        $.ajax({
                url : '/admin/manager/menu_edit.php',
                type : 'get',
                data : {'ajax':'del', 'ids':ids},
                success : function(data){
                    var data = eval("("+data+")");
                    if(data.code) {
                        alert(data.msg);
                    }
                    else {
                        location.reload();
                    }
                }
        });
    }
}

//批量删除
function delAll(chk_ids) {
    var idsarr = new Array();
    $("."+chk_ids).each(function(){
        if ($(this).prop('checked')) {
            idsarr.push($(this).val());
        }
    });
    var idsstr = idsarr.join(',');

    if (!idsstr) {
        alert('未选择删除项！');
        return false;
    }

    del(idsstr);

}
</script> 

<?php include SYSDIR_VIEW ."/common/footer.html";?>
